package com.farwolf.sysshare.module;

import android.app.Activity;
import android.content.Intent;

import com.farwolf.weex.annotation.WeexModule;
import com.farwolf.weex.base.WXModuleBase;
import com.taobao.weex.annotation.JSMethod;

import java.util.HashMap;

@WeexModule(name="sysShare")
public class WXSysShareModule extends WXModuleBase {


    @JSMethod
    public void share(HashMap param){
        String content=param.get("content")+"";
        String type=param.get("type")+"";
        Intent textIntent = new Intent(Intent.ACTION_SEND);
        if("image".equals(type)){
            textIntent.setType("image/*");
        }else{
            textIntent.setType("text/plain");
        }

//        textIntent.setType("image/*");
//        textIntent.setClassName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareToTimeLineUI");
        textIntent.putExtra(Intent.EXTRA_TEXT, content);
        ((Activity)getContext()).startActivity(Intent.createChooser(textIntent, "分享"));
    }

}
